import java.util.Stack;
public class reversePolishNotation {

    public void compute(String[] s){
        Stack<String> stack = new Stack<>();
        for(String c:s){
            switch (c){
                case "+":{
                    int numA = Integer.parseInt(stack.pop());//先出放后面
                    int numB = Integer.parseInt(stack.pop());
                    int res = numB+numA;
                    stack.push(String.valueOf(res));
                    break;
                }
                case "-":{
                    int numA = Integer.parseInt(stack.pop());//先出放后面
                    int numB = Integer.parseInt(stack.pop());
                    int res = numB-numA;
                    stack.push(String.valueOf(res));
                    break;
                }
                case "*":{
                    int numA = Integer.parseInt(stack.pop());//先出放后面
                    int numB = Integer.parseInt(stack.pop());
                    int res = numB*numA;
                    stack.push(String.valueOf(res));
                    break;
                }
                case "/":{
                    int numA = Integer.parseInt(stack.pop());//先出放后面
                    int numB = Integer.parseInt(stack.pop());
                    int res = numB/numA;
                    stack.push(String.valueOf(res));
                    break;
                }
                default:{
                    stack.push(c);
                }
            }
        }
        System.out.println(stack.peek());
    }
    public static void main(String[] args) {
        var main = new reversePolishNotation();
        main.compute(new String[]{"10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"});
    }
}
